<?php 
/**
 * 后台登陆控制器
 */
class LoginController extends Controller{
    
    public function index(){
    	if(IS_POST){
    		//实例化扩展UserModel模型
    		$model = K('User');
			if(!$userInfo = $model->vLogin()){
				$this->error($model->error);
			}
			//判断是否是后台用户
			if(!$model->isAdmin($userInfo['username'])){
				$this->error('用户名或密码错误');
			}
			//存入session
			$_SESSION['aname'] = $userInfo['username'];
			$_SESSION['aid'] = $userInfo['uid'];
			//提示登陆成功
			$this->success('登陆成功',U('Admin/Index/index'));
    	}
       $this->display(); 
    }
	
	
	/**
	 * 验证码
	 */
	public function code(){
	    $code = new Code();
		$code->show();
	}
	
	/**
	 * 退出
	 */
	public function out(){
	    session(NULL);
		$this->success('退出成功',U('Admin/Login/index'));
	}
	
	
 }
 
 
 
 
 
 
 
 
 
 
 





 ?>